import request from '@/common/http'
// import {convertRes2Blob} from "@/common/util";
import { dateFormat } from "@/utils/date";
export function getCode(query) {
  return request({
    url: '/admin/user/getCode',
    method: 'get',
    params: query
  })
}
//注销token
export const logout = () => {
  return request({
    url: '/auth/token/logout',
    method: 'delete'
  })
}
//验证验证码
export function checkCode(query) {
  return request({
    url: '/admin/user/checkCode',
    method: 'get',
    params: query
  })
}

//查询步骤
export function getAuthenticationSteps() {
  return request({
    url: '/eprise/enterprise/getAuthenticationSteps',
    method: 'get',

  })
}


export function editWorks(id) {
  return request({
    url: '/eprise/enterprise/getEntrustDetailById?entrustId=' + id,
    method: 'get',
    // params: query
  })
}
export function getOrderDetail(id) {
  return request({
    url: '/bank/bankOrder/getBankOrderDetail?orderId=' + id,
    method: 'get',

    // params: query
  })
}

export function getOrderDetail2(id) {
  return request({
    url: '/manage/entrust/getEntrustInfoDetail?entrustId=' + id,
    method: 'get',

    // params: query
  })
}
//最新的报价设置
export function getReqDetailLatest(query) {
  return request({
    url: '/bank/bankReq/getReqDetailLatest',
    method: 'get',
    params: query
  })
}
export function updateOrderStatus(row) {

  return request({
    url: '/bank/bankOrder/updateOrderStatus?orderId=' + row.orderId + '&orderOperate=' + row.orderOperate,
    method: 'put',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },

  })
}
export function getOrgsList(id) {
  return request({
    url: '/aliance/bctorg/getOrgList?leagueId=' + id,
    method: 'get',
    // params: query
  })
}

export function getOrgList(id, appId) {
  return request({
    url: '/aliance/bctorg/getOrgListByLeagueAndApp/' + id + '/' + appId,
    method: 'get',
    // params: query
  })
}

export function confirmPlatformDisc(obj) {
  return request({
    url: '/eprise/enterprise/confirmPlatformDisc',
    method: 'post',
    data: obj
  })
}
export function entrustqr(obj) {
  return request({
    url: '/eprise/enterprise/entrust',
    method: 'post',
    data: obj
  })
}
export function registeUser(obj) {
  return request({
    url: '/admin/user/registeUser',
    method: 'post',
    data: obj
  })
}
export function putaddOrg(obj) {
  return request({
    url: '/blockchain/kbapp',
    method: 'put',
    data: obj
  })
}

export function creditAgree(row) {
 let creditStartTime = dateFormat(
    row.creditStartTime,
    "YYYY-MM-DD HH:mm:ss"
  );
  let  creditEndTime = dateFormat(
    row.creditEndTime,
    "YYYY-MM-DD HH:mm:ss"
  );
  return request({
    url: '/bank/creditLimit/creditAgree?extraCreditApplyId=' + row.extraCreditApplyId+ '&creditLimit=' + row.creditLimit+ '&creditStartTime=' + creditStartTime+ '&creditEndTime=' + creditEndTime,
    method: 'put',
    //  data: obj
  })
}

//拒绝
export function creditReject(row) {
  return request({
    url: '/bank/creditLimit/creditReject?extraCreditApplyId=' + row,
    method: 'put',
    // data: obj
  })
}

//交易关闭
export function updateHolidaySwitch(row) {
  return request({
    url: '/bank/bankReq/updateTransactionSwitch?transactionSwitch=' + row.transactionSwitch + '&bankId=' + row.bankId,
    method: 'put',
    // data: obj
  })
}
//关闭节假日
export function setHolidaySwitch(row) {
  return request({
    url: '/bank/bankReq/updateHolidaySwitch?holidaySwitch=' + row.holidaySwitch + '&bankId=' + row.bankId,
    method: 'put',
    // data: obj
  })
}
//上传接口
export function uploadReqFile(obj) {
  return request({
    url: '/bank/bankReq/uploadReqFile',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data: obj
  })
}
//更新报价设置
export function setPriceBaseInfo(obj) {
  return request({
    url: '/bank/bankReq/setBaseReq',
    method: 'post',
    data: obj
  })
}
//开通
export function applyAuth(bankId) {
  return request({
    url: '/eprise/enterprise/applyAuth?bankId=' + bankId,
    method: 'post',

  })
}

//银行首页
export function getIndexData() {
  return request({
    url: '/bank/getBankIndexData',
    method: 'get',
    // data: obj
  })
}
//管理端
export function getIndexDataMaga() {
  return request({
    url: '/manage/manageIndex/getIndexData',
    method: 'get',
    // data: obj
  })
}
//额度授信列表
export function getCreditInfoList(row) {
  return request({
    url: '/bank/creditLimit/getCreditInfoList?enterpriseName=' + row.enterpriseName + '&creditStatus=' + row.creditStatus + '&current=' + row.current + '&size=' + row.size,
    method: 'get',
  })
}

export function logPage(row) {
  return request({
    url: '/admin/log/page?startTime=' + row.startTime + '&endTime=' + row.endTime + '&current=' + row.current + '&size=' + row.size,
    method: 'get',
  })
}


export function getOrgOptionList(id, current, size) {
  return request({
    url: '/blockchain/kbapp/getAppOrgList?id=' + id + '&current=' + current + '&size=' + size,
    method: 'get',
    // params: query
  })
}

export function delOrg(appId, orgId) {
  return request({
    url: '/blockchain/kborgapp/' + appId + '/' + orgId,
    method: 'delete'
  })
}

//删除应用
export function delApp(appId) {
  return request({
    url: '/blockchain/kbapp/' + appId,
    method: 'delete'
  })
}
//委托列表
export function getEntrustList(obj) {
  return request({
    url: '/manage/entrust/getEntrustList',
    method: 'post',
    data: obj
  })
}

//用户管理
export function getClientList(obj) {
  return request({
    url: '/manage/getClientList',
    method: 'post',
    data: obj
  })
}


export function getLeaguesList() {
  return request({
    url: '/aliance/league/getLeagueList',
    method: 'get',
    // params: query
  })
}

//立即试算-首页
export function creatAPPSy(row) {
  // let startLimit = dateFormat(row.expireTime, 'YYYYMMDD')
  const data = new FormData()
  // data.append('billImg', file)
  // data.append('billNo', row.billNo)
  data.append('acceptor', row.acceptor)
  // data.append('corpCode', row.corpCode)
  data.append('draftMoney', row.billMoney)
  data.append('endDate', row.expireTime)
  // data.append('id', row.id)
  return request({
    url: '/eprise/enterprise/queryPlatformPrice',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data
  })
}

//立即试算
export function creatAPP(file, row) {
  let startLimit = dateFormat(row.endDate, 'YYYYMMDD')
  const data = new FormData()
  data.append('billImg', file)
  data.append('billNo', row.billNo)
  data.append('bankNo', row.bankNo)
  data.append('corpCode', row.corpCode)
  data.append('draftMoney', row.draftMoney)
  data.append('endDate', startLimit)
  // data.append('id', row.id)
  return request({
    url: '/eprise/enterprise/queryPlatformPrice',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data
  })
}

//票据试算
// export function creatAPPpj(file, row) {
//   // let startLimit = dateFormat( row.expireTime, 'YYYY-MM-DD HH:mm:ss')
//   const data = new FormData()
//   data.append('billImg', file)
//   data.append('billNumber', row.billNumber)
//   data.append('acceptor', row.acceptor)
//   data.append('billMoney', row.billMoney)
//   data.append('expireTime', row.expireTime)
//   data.append('id', row.id)
//   return request({
//     url: '/eprise/enterprise/getRecommendBankList',
//     method: 'post',
//     headers: {
//       'Content-Type': 'multipart/form-data',
//     },
//     data
//   })
// }

export function creatAPPpj(file, row) {
  // let startLimit = dateFormat( row.expireTime, 'YYYY-MM-DD HH:mm:ss')
  const data = new FormData()
  data.append('billImg', file)
  data.append('billNo', row.billNumber)
  data.append('bankNo', row.acceptBankNumber)
  data.append('corpCode', row.corpCode)
  data.append('draftMoney', row.billMoney)
  data.append('endDate', row.expireTime)
  data.append('id', row.id)
  return request({
    url: '/eprise/enterprise/queryPlatformPrice',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data
  })
}


//首页立即试算
export function getRecommendResult(obj) {
  return request({
    url: '/eprise/enterprise/getRecommendResult',
    method: 'post',
    data: obj
  })
}

//委托中心列表
export function querywt(obj) {
  return request({
    url: '/eprise/enterprise/getEntrustList',
    method: 'post',
    data: obj
  })
}

//我的授信列表
export function querysx(obj) {
  return request({
    url: '/eprise/enterprise/getCreditList',
    method: 'post',
    data: obj
  })
}
//申请额度

export function shenq(bankId) {
  return request({
    url: '/eprise/enterprise/applyLimit?bankId=' + bankId,
    method: 'post',

  })
}
//我的授权querysq
export function querysq(obj) {
  return request({
    url: '/eprise/enterprise/getAuthorizationList',
    method: 'post',
    data: obj
  })
}
//客户中心
export function bankClient(query) {
  return request({
    url: '/bank/bankClient/getBankClientPageInfo',
    method: 'get',
    params: query
  })
}
//允许
export function addbh(obj) {
  return request({
    url: '/eprise/enterprise/authorizePass',
    method: 'post',
    data: obj
  })
}
//驳回addbhh
export function addbhh(obj) {
  return request({
    url: '/eprise/enterprise/authorizeReject',
    method: 'post',
    data: obj
  })
}
//消息列表queryxxx
export function queryxxx(obj) {
  return request({
    url: '/eprise/enterprise/getMessageList',
    method: 'post',
    data: obj
  })
}
//修改密码smps
export function smps(obj) {
  return request({
    url: '/admin/user/editPassword',
    method: 'post',
    data: obj
  })
}
//修改验证码ymzs
export function ymzs(obj) {
  return request({
    url: '/admin/user/editPhone',
    method: 'post',
    data: obj
  })
}
//基本信息creatzhanghugl
export function creatzhanghugl() {
  return request({
    url: '/admin/user/getUserInfo',
    method: 'get',
    // params: query
  })
}
//账户管理
export function zhguanli(obj) {
  return request({
    url: '/eprise/enterprise/accountManagement',
    method: 'post',
    data: obj
  })
}
//企业认证基本信息提交
export function baseSimm(obj) {
  return request({
    url: '/eprise/enterprise/uploadInfo',
    method: 'post',
    data: obj
  })
}
//经办人验证
export function jbryz(step) {
  return request({
    url: '/eprise/enterprise/authenticationSteps?step=' + step,
    method: 'post',

  })
}

export function getBillDetailById(obj) {
  return request({
    url: '/eprise/enterprise/getBillDetailById',
    method: 'post',
    data: obj
  })
}
//下载文件
export function downAgree(obj) {
  return request({
    url: '/eprise/enterprise/downAgree',
    method: 'post',
    data: obj
  })
}
//签署协议
export function signAgreement(check, step) {
  return request({
    url: '/eprise/enterprise/signAgreement?check=' + check + '&step=' + step,
    method: 'get',
    // params: query
  })
}
//订单中心列表
export function getBankOrderList(query) {
  return request({
    url: '/bank/bankOrder/getBankOrderList',
    method: 'get',
    params: query
  })
}
//获取二维码
export function makeQRCode() {
  return request({
    url: '/eprise/enterprise/makeQRCode',
    method: 'get',
    responseType:"blob"

  })
}
//认证结果
export function getAuthorizeResult(obj) {
  return request({
    url: '/eprise/enterprise/getAuthorizeResult',
    method: 'post',
    data: obj
  })
}
//查看证书
export function getUploadInfo() {
  return request({
    url: '/eprise/enterprise/getUploadInfo',
    method: 'get',
    // params: query
  })
}
//客户详情
export function getEnterpriseInfoDet(enterpriseId) {
  return request({
    url: '/bank/bankClient/getEnterpriseInfoDetail?enterpriseId=' + enterpriseId,
    method: 'get',
    //  params: query
  })
}
//查看证书图片
export function makeAuthPdf() {
  return request({
    url: '/eprise/enterprise/makeAuthPdf',
    method: 'get',
    responseType: 'blob',
    // params: query
  })
}
//查询票据
export function querypj(obj) {
  return request({
    url: '/eprise/enterprise/getBillList',
    method: 'post',
    data: obj
  })
}
//查询票据
export function addAuthorizationApply(obj) {
  return request({
    url: '/workflow/enterpriseAuthorize/addAuthorizationApply',
    method: 'post',
    data: obj
  })
}
//上传图片
export function creatChainCode(file, row) {
  let startLimit = dateFormat(row.endDate, 'YYYY-MM-DD HH:mm:ss')
  const data = new FormData()
  data.append('billImg', file)
  data.append('billNumber', row.bankNo)
  // data.append('bankNo', row.bankNo)
  // data.append('billNo', row.billNo)
   data.append('acceptor', row.bankNo)
  data.append('billMoney', row.draftMoney)
  data.append('expireTime', startLimit)
  // if(row.id) {
  //   data.append('id',row.id)
  // }
  return request({
    url: '/eprise/enterprise/uploadBill',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data
  })
}

//上传logo
export function uploadAvatar(file) {
  const data = new FormData()
  data.append('file', file)
  return request({
    url: '/admin/user/uploadAvatar ',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data
  })
}

//应用下架
export function appOff(obj) {
  return request({
    url: '/blockchain/kbapp/appOff/' + obj,
    method: 'put',
    // data: obj
  })
}

//下载应用包
// export function downloadApp (id) {
//   return request({
//     url: '/blockchain/kbapp/getAppPackageByOrgId?orgId=' + id,
//     method: 'get',
//     responseType:'blob',
//     // params: query
//   })
// }
// export function downloadApp(id,index) {
//   return request({
//     url: '/security/operate/downApp?orgId=' + id.id,
//     method: 'get',
//     responseType: 'blob'
//   }).then((response) => { // 处理返回的文件流
//     debugger
//     convertRes2Blob(response)
//   })
// }
